<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
		<title>系统日志列表</title>
		<link rel="stylesheet" href="/static/web/css/font-awesome.min.css">
		<link rel="stylesheet" href="/static/web/css/bootstrap.min.css">
		<link rel="stylesheet" href="/static/web/css/admin.css">
	</head>
	<body>
		<form name="formsearch">
			<table class="table shadow-sm my-3">
				<tr>
					<td>
						<input type="text" name="cip" id="cip" placeholder="请输入ip地址" class="admin-input-lg mr-3">
						<select name="adminid" id="adminid" class="admin-input-sm mr-3">
							<option value="0" selected>全部</option>
							<?php echo $adminlist?>
						</select>
						<select name="dtime" id="dtime" class="admin-input-sm">
							<option value="0" selected>全部</option>
							<option value="7">一周内</option>
							<option value="15">15天内</option>
							<option value="30">30天以内</option>
							<option value="60">60天以内</option>
						</select>
						<button type="submit" name="submit" class="btn btn-success btn-sm">搜索</button>
					</td>
				</tr>
			</table>
		</form>
		<form name="form1">
			<table class="table shadow-sm mb-3">
				<tr>
					<td colspan="7">日志管理</td>
				</tr>
				<tr align="center">
					<td width="6%">选择</td>
					<td width="12%">管理员</td>
					<td width="30%">浏览文件</td>
					<td width="6%">访问方式</td>
					<td width="10%">地址</td>
					<td width="10%">时间</td>
					<td>参数</td>
				</tr>
				{dede:datalist empty='<tr><td colspan="7" align="center">暂无记录</td></tr>'}
				<tr align="center">
					<td><input type="checkbox" name="logs" id="logs" value="{dede:field.lid/}"></td>
					<td>{dede:field.userid/}</td>
					<td><input type="text" name="t0" value="{dede:field.filename/}" class="admin-input-lg"></td>
					<td>{dede:field.method/}</td>
					<td>{dede:field.cip/}</td>
					<td>{dede:field.dtime function="MyDate('y/m/d H:i:s',@me)"/}</td>
					<td><input type="text" name="t1" value="{dede:field.query/}" class="admin-input-lg"></td>
				</tr>
				{/dede:datalist}
				<tr>
					<td colspan="7">
						<button type="button" onclick="ReSel();" class="btn btn-success btn-sm">反选</button>
						<button type="button" onclick="DelSel();" class="btn btn-danger btn-sm">删除</button>
						<button type="button" onclick="ClearLog();" class="btn btn-danger btn-sm">清空所有日志</button>
					</td>
				</tr>
				<tr>
					<td colspan="7" align="center">{dede:pagelist listsize='6'/}</td>
				</tr>
			</table>
		</form>
		<script>
			//获得选中文件的文件名
			function getCheckboxItem() {
				var allSel = '';
				if (document.form1.logs.value) return document.form1.logs.value;
				for (i = 0; i < document.form1.logs.length; i++) {
					if (document.form1.logs[i].checked) {
						if (allSel == "")
							allSel = document.form1.logs[i].value;
						else
							allSel = allSel + "`" + document.form1.logs[i].value;
					}
				}
				return allSel;
			}
			function ReSel() {
				for (i = 0; i < document.form1.logs.length; i++) {
					if (document.form1.logs[i].checked) document.form1.logs[i].checked = false;
					else document.form1.logs[i].checked = true;
				}
			}
			function DelSel() {
				var nid = getCheckboxItem();
				if (nid == "") {
					alert("请选择项目");
					return;
				}
				location.href = "log_edit.php?dopost=del&ids=" + nid;
			}
			function ClearLog() {
				location.href = "log_edit.php?dopost=clear";
			}
		</script>
	</body>
</html>